cc.Class({
    extends: cc.Component,

    properties: {

    },

    start() {
        this.ctx = this.node.getComponent(cc.Graphics);

        this.ctx.lineCap = cc.Graphics.LineCap.ROUND;

    },

    doDraw(x0, y0, x1, y1, color, lineWidth) {
         console.log("doDraw：", x0, y0, x1, y1, color, lineWidth)
        let ccColor = cc.Color.BLACK;
        switch (color) {
            case "WHITE":
                ccColor = cc.Color.WHITE;
                lineWidth = 3 * lineWidth;
                break;
            case "BLACK":
                ccColor = cc.Color.BLACK;
                break;
            case "RED":
                ccColor = cc.Color.RED;
                break;
            case "GREEN":
                ccColor = cc.Color.GREEN;
                break;
            case "BLUE":
                ccColor = cc.Color.BLUE;
                break;
            case "YELLOW":
                ccColor = cc.Color.YELLOW;
                break;
            case "PURPLE":
                ccColor = new cc.Color(255, 0, 255);
                break;
            default:
                break;
        }
        this.ctx.strokeColor = ccColor;
        this.ctx.fillColor = ccColor;
        this.ctx.lineWidth = lineWidth;

        this.ctx.moveTo(x0, y0);
        this.ctx.lineTo(x1, y1);
        this.ctx.stroke();
        this.ctx.moveTo(x1, y1);
    },

    clearDraw() {
        this.ctx.clear()
    }
});
